
#include <iostream>
#include <map>
using namespace std;

#include "CPhoneBook.h"


CPhoneBook::CPhoneBook()
{
}


CPhoneBook::~CPhoneBook()
{
}


bool CPhoneBook::addEntry(string theName, int theNumber)
{
    myPhoneBook.insert(pair<string, int>(theName, theNumber));
    return true;
}


bool CPhoneBook::deleteEntry(string theName)
{
    myPhoneBook.erase(theName);
    return true;
}


int CPhoneBook::searchNumber(string theName)
{
    return myPhoneBook.find(theName)->second;
}


void CPhoneBook::print()
{
    cout << "----> Phone Book <----" << endl;

    map<string, int>::iterator theIterator;

    for (theIterator = myPhoneBook.begin(); theIterator != myPhoneBook.end(); theIterator++)
    {
        cout << (*theIterator).first << " => " << (*theIterator).second << endl;
    }
}
